<template>
    <el-dialog :visible.sync="dialog" :title="isAdd ? '课程详情' : '课程详情'" append-to-body width="370px">
        <el-form ref="form" :model="form"  size="small" label-width="100px" append-to-body>
            <el-form-item label="科目:">
                 <div>{{form.subjectName}}</div>
            </el-form-item>
            <el-form-item label="上课时间:">
                 <div>{{form.startTimeString}} <span style="margin:0 5px">-</span>{{form.endTimeString}}</div>
            </el-form-item>            
            
            <el-form-item label="主讲老师:">
                 <div>{{form.lectureTeaId}}</div>
            </el-form-item>
            <el-form-item label="听讲学校:">
                 <div>{{form.schName}}</div>
            </el-form-item>
            <el-form-item label="听讲老师:">
                 <div>{{form.assistTeaId}}</div>
            </el-form-item>
            <el-form-item label="听讲班级:">
                 <div>{{form.assistClassName}}</div>
            </el-form-item>
            <el-form-item label="备注:">
                 <div>{{form.planRemarks}}</div>
            </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer" v-if="checkPermission(['rili_all','rili_del'])" >
            <el-popover
              placement="top"
              width="160"
              v-model="visible">
              <p>确认删除该课程吗?</p>
              <div style="text-align: right; margin: 0">
                <el-button size="mini" type="text" @click="visible = false">取消</el-button>
                <el-button type="danger" size="mini" @click="doSubmit">确定</el-button>
              </div>
              <el-button  slot="reference" :loading="loading" type="danger">删除</el-button>
            </el-popover>
        </div>
    </el-dialog>
</template>

<script>
import checkPermission from '@/utils/permission' 
import { riliDel } from '@/api/request'
export default {
    props: {
        isAdd: {
          type: Boolean,
          required: true
        },
    },
    data() {
        return {
            visible: false,
            disabled:false,
            loading: false, dialog: false, 
            form: {
                id:'',
                startTimeString:'',
                endTimeString: '', //上课时间
                subjectName: '',  //科目
                lectureTeaId:'',  //主讲老师
                schName:'',       //听讲学校
                assistTeaId:'',   //听讲老师
                assistClassName:'', //听讲班级
                planRemarks:'',   //备注
            },            
        }
    },
    methods: {
        checkPermission,
        cancel(){
            this.dialog  = false
        },
        doSubmit(){
            let ids = [];
            ids.unshift(this.form.id)
            riliDel(ids).then(res => {
                this.$message({
                    message: '删除成功',
                    type: 'success'
                });
                this.visible = false
                this.dialog  = false
                this.$parent.toQuery()
            })
        },
        
    },

}
</script>


<style scoped lang="scss">
.el-form-item--small.el-form-item{
    margin-bottom: 3px!important;
}
</style>

